package com.asset.salesforce.service;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.asset.salesforce.dao.RoleShiroDaoImpl;
import com.asset.salesforce.domain.Role;

@Service
@Transactional(readOnly=true)
public class RoleShiroService {
	
	@Autowired
	private RoleShiroDaoImpl roleShiroDaoImpl;
	
	@Transactional(readOnly=false)
	public void editRole(Role role){
		roleShiroDaoImpl.editRole(role);
	}
	
	@Transactional(readOnly=false)
	public void addRole(Role role) {
		roleShiroDaoImpl.addRole(role);
	}

	@Transactional(readOnly=false)
	public void deleteRole(Role role) {
		roleShiroDaoImpl.deleteRole(role);
	}
	

	@Transactional(readOnly=true)
	public List<Role> getAllRoles() {
	 return	roleShiroDaoImpl.getAllRoles();
	}

	@Transactional(readOnly=true)
	public Role getRoleById(Integer roleId) {
		 return	roleShiroDaoImpl.getRoleById((Integer)SecurityUtils.getSubject().getPrincipal());
	}

	@Transactional(readOnly=true)
	public Role findRole(String rolename) {
		 return	roleShiroDaoImpl.findRole(rolename);
	}
	
	@Transactional(readOnly=true)
	public Long countRole() {
		return roleShiroDaoImpl.countRole();
	}


}
